<template>
    <div>
        <!--        Vue 还提供了 v-model 指令，它能轻松实现表单输入和应用状态之间的双向绑定 -->
        <p>{{ message }}</p>
        <input v-model="message">
        <hr>


        <span>Multiline message is:</span>
        <p style="white-space: pre-line;">{{ message2 }}</p>
        <br>
        <textarea v-model="message2" placeholder="add multiple lines"></textarea>
        <hr>
        <input type="checkbox" id="jack" value="Jack" v-model="checkedNames">
        <label for="jack">Jack</label>
        <input type="checkbox" id="john" value="John" v-model="checkedNames">
        <label for="john">John</label>
        <input type="checkbox" id="mike" value="Mike" v-model="checkedNames">
        <label for="mike">Mike</label>
        <br>
        <span>Checked names: {{ checkedNames }}</span>

        <hr>
        <input type="radio" id="one" value="One" v-model="picked">
        <label for="one">One</label>
        <br>
        <input type="radio" id="two" value="Two" v-model="picked">
        <label for="two">Two</label>
        <br>
        <span>Picked: {{ picked }}</span>

        <hr>
        <select v-model="selected">
            <option disabled value="">请选择</option>
            <option>A</option>
            <option>B</option>
            <option>C</option>
        </select>
        <span>Selected: {{ selected }}</span>

        <hr>
        <select v-model="selected2" multiple style="width: 50px;">
            <option>A</option>
            <option>B</option>
            <option>C</option>
        </select>
        <br>
        <span>Selected: {{ selected2 }}</span>

        <hr>
        <select v-model="selected3">
            <option v-for="option in options" v-bind:value="option.value">
                {{ option.text }}
            </option>
        </select>
        <span>Selected: {{ selected3 }}</span>

        <hr>
        <buttonCounter></buttonCounter>

    </div>
</template>

<script>
    import buttonCounter from "../components/buttonCounter";

    export default {
        name: "DemoVmodel",
        components:{
            buttonCounter
        },
        data() {
            return {
                message: 'Hello Vue!',
                message2: 'Hello Vue!',
                checkedNames: [],
                picked: '',
                selected:'',
                selected2:[],
                selected3: 'A',
                options: [
                    { text: 'One', value: 'A' },
                    { text: 'Two', value: 'B' },
                    { text: 'Three', value: 'C' }
                ]
            }
        }
    }
</script>

<style scoped>

</style>
